package com.xiaoyu.izf.service;

import com.xiaoyu.izf.model.ManualVipUpgradeLog;
import com.xiaoyu.izf.repository.ManualVipUpgradeLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;

@Service
public class ManualVipUpgradeLogService {

    @Autowired
    private ManualVipUpgradeLogDao manualVipUpgradeLogDao;

    @Transactional
    public ManualVipUpgradeLog add(int uid,int beforeVip,int afterVip){
        ManualVipUpgradeLog log = new ManualVipUpgradeLog();
        log.setUid(uid);
        log.setBeforeVip(beforeVip);
        log.setAfterVip(afterVip);
        log.setCreateTime(new Timestamp(System.currentTimeMillis()));
        return manualVipUpgradeLogDao.save(log);
    }

    /**
     * 手动给指定用户最后一次升级的记录
     * @param uid
     * @return
     */
    public ManualVipUpgradeLog latest(int uid){
        return manualVipUpgradeLogDao.latest(uid);
    }
}
